<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8"/>
    <title>
        系统设置
    </title>
    <meta content="webkit" name="renderer"/>
    <meta content="IE=edge,chrome=1" http-equiv="X-UA-Compatible"/>
    <meta content="width=device-width, initial-scale=1, maximum-scale=1" name="viewport"/>
    <meta content="black" name="apple-mobile-web-app-status-bar-style"/>
    <meta content="yes" name="apple-mobile-web-app-capable"/>
    <meta content="telephone=no" name="format-detection"/>
    <link href="css/main.css" media="all" rel="stylesheet"/>
    <script src="lib/loading/okLoading.js" type="text/javascript"></script>
</head>
<body>
<div class="x-nav">
    <span class="layui-breadcrumb"> <a><cite>首页</cite></a> <a><cite>系统管理</cite></a> <a><cite>系统设置</cite></a> </span>
    <a class="layui-btn layui-btn-small" href="javascript:location.replace(location.href);"
       style="line-height:1.6em;margin-top:3px;float:right" title="刷新"><i class="layui-icon"
                                                                            style="line-height:30px">ဂ</i></a>
</div>
<div class="x-body">
    <form action="" class="layui-form layui-form-pane">
        <div class="layui-tab layui-tab-brief" lay-filter="docDemoTabBrief">
            <ul class="layui-tab-title">
                <li class="layui-this">网站设置</li>
                <li>安全设置</li>
                <li>关闭网站</li>
            </ul>
            <div class="layui-tab-content">
                <div class="layui-tab-item layui-show">
                    <input name="id" type="hidden" value="1"/>
                    <div class="layui-form-item">
                        <label class="layui-form-label"> <span class="x-red">*</span>网站名称 </label>
                        <div class="layui-input-block">
                            <input autocomplete="off" class="layui-input" name="name"
                                   placeholder="控制在25个字、50个字节以内"
                                   type="text" value=""/>
                        </div>
                    </div>
                    <div class="layui-form-item">
                        <label class="layui-form-label"> <span class="x-red">*</span>关键词 </label>
                        <div class="layui-input-block">
                            <input autocomplete="off" class="layui-input" name="keywords"
                                   placeholder="5个左右,8汉字以内,用英文,隔开" type="text" value=""/>
                        </div>
                    </div>
                    <div class="layui-form-item">
                        <label class="layui-form-label"> <span class="x-red">*</span>描述 </label>
                        <div class="layui-input-block">
                            <input autocomplete="off" class="layui-input" name="desc"
                                   placeholder="空制在80个汉字，160个字符以内"
                                   type="text" value=""/>
                        </div>
                    </div>
                    <div class="layui-form-item">
                        <label class="layui-form-label"> <span class="x-red">*</span>网站LOGO </label>
                        <div class="layui-input-block">
                            <div class="site-demo-upbar">
                                <div class=" layui-upload-button" style="border:#FFFFFF ;">
                                    <button class="layui-btn" id="test1" type="button"><i class="layui-icon"></i>上传图片
                                    </button>
                                    <input accept="undefined" class="layui-upload" id="previewImg" name="img"
                                           onchange="upload(this,1)" type="file"/>
                                </div>
                            </div>
                        </div>
                    </div>
                    <div class="layui-form-item imgs" id="imgshow">
                        <label class="layui-form-label">LOGO展示 </label>
                        <img id="pimages" name="pimages" src="./images/tx.jpg" style="width: 100px;height: 100px;"/>
                        <input id="avatar" name="images" required="" type="hidden" value="./images/tx.jpg"/>
                    </div>
                    <div class="layui-form-item">
                        <label class="layui-form-label"> <span class="x-red">*</span>底部版权信息 </label>
                        <div class="layui-input-block">
                            <input autocomplete="off" class="layui-input" name="copyright"
                                   placeholder="&copy; 2016 main"
                                   type="text" value=""/>
                        </div>
                    </div>
                    <div class="layui-form-item">
                        <label class="layui-form-label"> <span class="x-red">*</span>备案号 </label>
                        <div class="layui-input-block">
                            <input autocomplete="off" class="layui-input" name="record" placeholder="XICP备00000000号"
                                   type="text" value=""/>
                        </div>
                    </div>
                    <div class="layui-form-item layui-form-text">
                        <label class="layui-form-label"> <span class="x-red">*</span>统计代码 </label>
                        <div class="layui-input-block">
                            <textarea class="layui-textarea" name="statistics"
                                      placeholder="请输入内容">           11000</textarea>
                        </div>
                    </div>
                    <div class="layui-form-item">
                        <button class="layui-btn" lay-filter="*" lay-submit=""> 保存</button>
                    </div>
                    <div style="height:100px;"></div>
                </div>
                <div class="layui-tab-item">
                    <div class="layui-form-item layui-form-text">
                        <label class="layui-form-label"> <span class="x-red">*</span>允许访问后台的IP列表 </label>
                        <div class="layui-input-block">
                            <textarea class="layui-textarea" name="allow_ip"
                                      placeholder="请输入内容">        127.0.0.1</textarea>
                        </div>
                    </div>
                    <div class="layui-form-item">
                        <label class="layui-form-label"> <span class="x-red">*</span>最大次数 </label>
                        <div class="layui-input-inline">
                            <input autocomplete="off" class="layui-input" lay-verify="number" min="0"
                                   name="max_count" type="number" value="5"/>
                        </div>
                    </div>
                    <div class="layui-form-item">
                        <button class="layui-btn" lay-filter="*" lay-submit=""> 保存</button>
                    </div>
                </div>
                <div class="layui-tab-item">
                    <div class="layui-form-item">
                        <label class="layui-form-label" for="AppId"> <span class="x-red">*</span>是否开启 </label>
                        <div class="layui-input-block">
                            <input $set.status="=" 1}="" checked="checked" f}="" lay-filter="switchTest"
                                   lay-skin="switch" lay-text="ON|OFF"
                                   name="status" title="开关" type="checkbox" {="" {if=""/>
                        </div>
                    </div>
                    <div class="layui-form-item">
                        <label class="layui-form-label" for="L_repass"> </label>
                        <button class="layui-btn" lay-filter="*" lay-submit=""> 保存</button>
                    </div>
                </div>
            </div>
        </div>
    </form>
</div>
<script charset="utf-8" src="lib/layui/layui.js"></script>
<script charset="utf-8" src="js/x-layui.js"></script>
<script>
    layui.use(['element', 'layer', 'form'], function () {
        $ = layui.jquery;//jquery
        lement = layui.element();//面包导航
        layer = layui.layer;//弹出层
        form = layui.form();
        okLoading.close($);


        //监听提交
        form.on('submit(*)', function (data) {
            var data = data.field;
            $.ajax({
                type: "post",
                url: "xxx",
                data: data,
                success: function (data) {
                    if (data.status == 1) {
                        layer.msg(data.info, {icon: 1, time: 1000});
                        setTimeout(function () {
                            window.parent.location.reload();
                            var index = parent.layer.getFrameIndex(window.name);
                            parent.layer.close(index);
                        }, 1000);
                        return false;
                    } else {
                        layer.msg(data.info, {icon: 5, time: 2000});
                        return false;
                    }
                }
            });
            return false;
        });

    })
</script>
<script>
    //LOGO上传
    function upload(obj, id) {
        var formData = new FormData();
        formData.append('img', $('#previewImg')[0].files[0]);
        formData.append('id', id);//将id追加再id中
        layer.msg('图片上传中', {icon: 16});
        $.ajax({
            type: "post",
            processData: false,
            contentType: false,
            url: "xxx",
            data: formData,
            success: function (data) {
                if (data.status == 1) {
                    //console.log(data.image_name);
                    layer.closeAll('loading');
                    //layer.msg(data.info,{icon:1,time:1000});
                    $("#pimages").attr('src', data.image_name);
                    $("#avatar").val(data.image_name);
                    $(".imgs").show();
                    return false;
                } else {
                    layer.msg(data.info, {icon: 2, time: 1000});
                }
            }
        });
    }
</script>
</body>
</html>